<?php

include_once 'Classes/PHPCodeProvider.php';

$options = new CodeGeneratorOptions();
$writer = new IndentedTextWriter();
$provider = new PHPCodeProvider();

/*
 * Create a reference to a property named 'attemptNumber'
 * of the current object
 */

$fieldReference1 = new FieldReferenceExpression(
    'attemptNumber', new ThisReferenceExpression());

$provider->generateCodeFromExpression($fieldReference1, $writer, $options);

echo '<pre>' . 
    str_replace('<br />', '', highlight_string($writer->get_String(), true)) 
        . '<pre/>';

$writer->clear();

/*
 * Create a reference to a property named 'myProperty'
 * of an object named 'myObject'
 */

$fieldReference2 = new FieldReferenceExpression(
    'myProperty', new VariableReferenceExpression('myObject'));

$provider->generateCodeFromExpression($fieldReference2, $writer, $options);

echo '<pre>' . 
    str_replace('<br />', '', highlight_string($writer->get_String(), true)) 
        . '<pre/>';

/*
 * The output should be:
 * 
 * $this->attemptNumber
 *
 * $myObject->myProperty
 * 
 */

?>
